package com.dhcc.sdc.busi.controller;


import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.plugins.Page;
import com.dhcc.core.framework.base.controller.BaseController;
import com.dhcc.core.framework.base.warpper.EmptyWarpper;
import com.dhcc.core.framework.exception.BizException;
import com.dhcc.core.framework.exception.BizExceptionEnum;
import com.dhcc.core.framework.result.R;
import com.dhcc.core.framework.result.page.PageFactory;
import com.dhcc.core.framework.util.CommonUtil;



import com.dhcc.sdc.busi.entity.SdcBusiQcMrlistEntity;
import com.dhcc.sdc.busi.service.ISdcBusiQcMrlistService;


/**
 * 在院质控入组记录
 * 
 * @ClassName: SdcBusiQcMrlistController
 * @Description: TODO
 * @author sunyingjie
 * @date 2022-12-06 09:51:12
 */
@Controller
@RequestMapping("${sys.backendPath}/sdc/sdcbusiqcmrlist")
public class SdcBusiQcMrlistController extends BaseController {

	private String PREFIX = "/backend/busi/sdcbusiqcmrlist/";

	@Autowired
	private ISdcBusiQcMrlistService sdcBusiQcMrlistService;
	

    /**
     * 跳转到在院质控入组记录列表首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "sdcbusiqcmrlist.html";
    }
	
    /**
     * 跳转到新增在院质控入组记录
     */
    @RequestMapping("/to_add")
    public String toAdd() {
        return PREFIX + "sdcbusiqcmrlist_add.html";
    }
	
	/**
     * 跳转到修改在院质控入组记录
     */
    @RequestMapping("/to_update/{sdcBusiQcMrlistId}")
    public String toUpdate(@PathVariable Integer sdcBusiQcMrlistId, Model model) {
        SdcBusiQcMrlistEntity sdcBusiQcMrlist = this.sdcBusiQcMrlistService.selectById(sdcBusiQcMrlistId);
        model.addAttribute("sdcBusiQcMrlist",sdcBusiQcMrlist);
        return PREFIX + "sdcbusiqcmrlist_edit.html";
    }

    /**
     * 获取在院质控入组记录列表
     */
	@SuppressWarnings("unchecked")
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(@RequestParam Map<String, Object> params) {
		Page<SdcBusiQcMrlistEntity> page = new PageFactory<SdcBusiQcMrlistEntity>().defaultPage();
        List<SdcBusiQcMrlistEntity> result = this.sdcBusiQcMrlistService.page(page,params);
        page.setRecords((List<SdcBusiQcMrlistEntity>) new EmptyWarpper(result).warp());
        return R.packForBT(page);
    }

    /**
     * 新增在院质控入组记录
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(SdcBusiQcMrlistEntity sdcBusiQcMrlist) {
        if (CommonUtil.isOneEmpty(sdcBusiQcMrlist)) {
            throw new BizException(BizExceptionEnum.REQUEST_NULL);
        }
        this.sdcBusiQcMrlistService.insert(sdcBusiQcMrlist);
        return R.ok();
    }

    /**
     * 删除在院质控入组记录
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer sdcBusiQcMrlistId) {
	
        this.sdcBusiQcMrlistService.deleteById(sdcBusiQcMrlistId);

        return R.ok();
    }

    /**
     * 修改在院质控入组记录
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(SdcBusiQcMrlistEntity sdcBusiQcMrlist) {
        if (CommonUtil.isOneEmpty(sdcBusiQcMrlist)) {
            throw new BizException(BizExceptionEnum.REQUEST_NULL);
        }
        this.sdcBusiQcMrlistService.updateById(sdcBusiQcMrlist);
        return R.ok();
    }
	
}
